package com.laolei.core.kafka;

import java.io.Serializable;

import org.apache.kafka.clients.producer.Partitioner;
import org.apache.kafka.common.serialization.Serializer;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.DeprecatedConfigurationProperty;

@ConfigurationProperties(prefix = "spring.kafka.producer")
public class ProducerConfig implements Serializable {
	private static final long serialVersionUID = 1L;
	/**
	 * 默认值: org.apache.kafka.common.serialization.StringSerializer
	 */
	private Class<Serializer<?>> keySerializer;
	/**
	 * 默认值: org.springframework.kafka.support.serializer.JsonSerializer
	 */
	private Class<Serializer<?>> valueSerializer;
	/**
	 * 默认值:1
	 */
	private String acks = "1";
	/**
	 * 默认值:33554432
	 */
	private Long bufferMemory = 33554432L;
	/**
	 * 默认值:none
	 */
	private String compressionType = "none";
	/**
	 * 默认值:0
	 */
	private int retries = 0;
	/**
	 * 默认值:16384
	 */
	private int batchSize = 16384;
	/**
	 * 默认值:0
	 */
	private Long lingerMs = 0L;
	/**
	 * 默认值:60000
	 */
	private Long maxBlockMs = 60000L;
	/**
	 * 默认值:1048576
	 */
	private int maxRequestSize = 1048576;
	/**
	 * 默认值:class org.apache.kafka.clients.producer.internals.DefaultPartitioner
	 */
	private Class<? extends Partitioner> partitionerClass = org.apache.kafka.clients.producer.internals.DefaultPartitioner.class;
	/**
	 * 默认值:30000
	 */
	private int requestTimeoutMs = 30000;
	/**
	 * 默认值:5
	 */
	private int maxInFlightRequestsPerConnection = 5;

	public Class<Serializer<?>> getKeySerializer() {
		return keySerializer;
	}

	public void setKeySerializer(Class<Serializer<?>> keySerializer) {
		this.keySerializer = keySerializer;
	}

	public Class<Serializer<?>> getValueSerializer() {
		return valueSerializer;
	}

	public void setValueSerializer(Class<Serializer<?>> valueSerializer) {
		this.valueSerializer = valueSerializer;
	}

	public String getAcks() {
		return acks;
	}

	public void setAcks(String acks) {
		this.acks = acks;
	}

	public Long getBufferMemory() {
		return bufferMemory;
	}

	public void setBufferMemory(Long bufferMemory) {
		this.bufferMemory = bufferMemory;
	}

	public String getCompressionType() {
		return compressionType;
	}

	public void setCompressionType(String compressionType) {
		this.compressionType = compressionType;
	}

	public int getRetries() {
		return retries;
	}

	public void setRetries(int retries) {
		this.retries = retries;
	}

	public int getBatchSize() {
		return batchSize;
	}

	public void setBatchSize(int batchSize) {
		this.batchSize = batchSize;
	}

	public Long getLingerMs() {
		return lingerMs;
	}

	public void setLingerMs(Long lingerMs) {
		this.lingerMs = lingerMs;
	}

	public Long getMaxBlockMs() {
		return maxBlockMs;
	}

	public void setMaxBlockMs(Long maxBlockMs) {
		this.maxBlockMs = maxBlockMs;
	}

	public int getMaxRequestSize() {
		return maxRequestSize;
	}

	public void setMaxRequestSize(int maxRequestSize) {
		this.maxRequestSize = maxRequestSize;
	}

	public Class<? extends Partitioner> getPartitionerClass() {
		return partitionerClass;
	}

	public void setPartitionerClass(Class<? extends Partitioner> partitionerClass) {
		this.partitionerClass = partitionerClass;
	}

	public int getMaxInFlightRequestsPerConnection() {
		return maxInFlightRequestsPerConnection;
	}

	public void setMaxInFlightRequestsPerConnection(int maxInFlightRequestsPerConnection) {
		this.maxInFlightRequestsPerConnection = maxInFlightRequestsPerConnection;
	}

	public int getRequestTimeoutMs() {
		return requestTimeoutMs;
	}

	public void setRequestTimeoutMs(int requestTimeoutMs) {
		this.requestTimeoutMs = requestTimeoutMs;
	}
}
